<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<!-- Mirrored from www.wolfssl.com/wolfSSL/Docs_yaSSL_Architecture_and_Design.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Jan 2017 13:24:08 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8" /><!-- /Added by HTTrack -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="Generator" content="iWeb 3.0.4"/>
<meta name="iWeb-Build" content="local-build-20170103"/>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<meta name="viewport" content="width=770"/>
<title>wolfSSL - Docs | yaSSL Architecture and Design</title>
<link rel="stylesheet" type="text/css" media="screen,print" href="Docs_yaSSL_Architecture_and_Design_files/Docs_yaSSL_Architecture_and_Design.css"/>
<!--[if lt IE 8]><link rel='stylesheet' type='text/css' media='screen,print' href='Docs_yaSSL_Architecture_and_Design_files/Docs_yaSSL_Architecture_and_DesignIE.css'/><![endif]-->
<!--[if gte IE 8]><link rel='stylesheet' type='text/css' media='screen,print' href='Media/IE8.css'/><![endif]-->
<script type="text/javascript" src="Scripts/iWebSite.js"></script>
<script type="text/javascript" src="Docs_yaSSL_Architecture_and_Design_files/Docs_yaSSL_Architecture_and_Design.js"></script>
<meta name="description" content="Architecture and design information about the yaSSL SSL library and the TaoCrypt crypto library, including cryptography, TCP/IP, certificates, input/output, threads, and memory usage."/><meta name="keywords" content="ssl, embedded ssl, ssl documentation, ssl library, tls library, embedded tls, open source ssl, openssl alternatives, encryption libraries, vxworks ssl, Linux ssl, mysql ssl, cryptography library, aes cryptography, C++ ssl, crypto source code, crypto library, md5, aes, sha1, gpl ssl, small openssl"/><meta name="robots" content="follow,index"/> <script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','../../www.google-analytics.com/analytics.js','ga');ga('create','UA-64826966-1','auto');ga('send','pageview');</script>
 
<script>//<![CDATA[
window.zEmbed||function(e,t){var n,o,d,i,s,a=[],r=document.createElement("iframe");window.zEmbed=function(){a.push(arguments)},window.zE=window.zE||window.zEmbed,r.src="javascript:false",r.title="",r.role="presentation",(r.frameElement||r).style.cssText="display: none",d=document.getElementsByTagName("script"),d=d[d.length-1],d.parentNode.insertBefore(r,d),i=r.contentWindow,s=i.document;try{o=s}catch(c){n=document.domain,r.src='javascript:var d=document.open();d.domain="'+n+'";void(0);',o=s}o.open()._l=function(){var o=this.createElement("script");n&&(this.domain=n),o.id="js-iframe-async",o.src=e,this.t=+new Date,this.zendeskHost=t,this.zEQueue=a,this.body.appendChild(o)},o.write('<body onload="document._l();">'),o.close()}("../../assets.zendesk.com/embeddable_framework/main.js","wolfssl.zendesk.com");
//]]></script>
  </head>
<body style="background: rgb(255, 255, 255); margin: 0pt; " onload="onPageLoad();">
<div style="text-align: center; ">
<div style="margin-bottom: 20px; margin-left: auto; margin-right: auto; margin-top: 20px; overflow: hidden; position: relative; word-wrap: break-word;  background: rgb(255, 255, 255); text-align: left; width: 770px; " id="body_content">
<div style="float: left; margin-left: 0px; position: relative; width: 770px; z-index: 0; " id="nav_layer">
<div style="height: 0px; line-height: 0px; " class="bumper"> </div>
<div style="clear: both; height: 0px; line-height: 0px; " class="spacer"> </div>
</div>
<div style="float: left; height: 0px; line-height: 0px; margin-left: 0px; position: relative; width: 770px; z-index: 10; " id="header_layer">
<div style="height: 0px; line-height: 0px; " class="bumper"> </div>
</div>
<div style="margin-left: 0px; position: relative; width: 770px; z-index: 5; " id="body_layer">
<div style="height: 0px; line-height: 0px; " class="bumper"> </div>
<div id="id1" style="height: 5767px; left: 48px; position: absolute; top: 231px; width: 684px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_684_5767" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-top: 0pt; " class="paragraph_style">I. General Architecture<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">The yaSSL embedded SSL library implements the SSL 3.0, TLS 1.0, and TLS 1.1 protocols. Two record layer protocols exist within SSL, the message layer and the handshake layer. Handshake messages are used to negotiate a common cipher suite, create secrets, and enable a secure connection. The message layer encapsulates the handshake layer while also supporting alert processing and application data transfer.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style">II. Cryptography<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">By default, yaSSL uses the cryptographic services provided by TaoCrypt, which is based in part on CryptoPP (see below). TaoCrypt aims to be more portable while only providing the functionality necessary for SSL-type needs. TaoCrypt Provides MD2, MD4, MD5, SHA-1, RIPEMD, HMAC, DES, 3DES, AES, ARC4, RSA, DSS, DH, and PKCS#5 PBKDF2, SHA-2, Random Number Generation, Large Integer support, and base 16/64 encoding/decoding. We've also added the Rabbit and HC-128 ciphers, public domain stream ciphers from the EU's eSTREAM project. Rabbit is potentially useful to those encrypting streaming media in high performance, high demand environments.  RABBIT is nearly twice as fast as RC4 and HC-128 is about 5 times as fast! TaoCrypt is currently in the process of getting FIPS 140-2 level one validation. Should you need immediate support for a FIPS validated crypto module, then see CryptoPP below.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">Descriptions and explanations of the algorithms and protocols that are used by yaSSL products can be found on our <a class="class1" title="http://www.yassl.com/yaSSL/Docs_References.html" href="http://www.yassl.com/yaSSL/Docs_References.html">Algorithm and Protocol Reference</a> page.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style">III. CryptoPP<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">CryptoPP can also be used to handle cryptography and crypto related details. Just define USE_CYPTOPP_LIB while compiling yaSSL. RSA, DES, 3DES, ARC4, MD5, SHA-1, and DSS are currently used by yaSSL, as well as CryptoPP's cryptographically secure random number generator, large Integer support, and base64 encoding/decoding. yaSSL declares all of its cryptographic needs in the header file crypto_wrapper.hpp. Nothing in the header file relies on the details of CryptoPP, i.e., any other library may be substituted in place of CryptoPP by switching out the desired functionality in crypto_wrapper.cpp. <br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">More information about CryptoPP, including source download, may be obtained at <a title="http://www.cryptopp.com/" href="http://www.cryptopp.com/">cryptopp.com</a>. Should you need a FIPS 140-2 level one crypto module for your use with yaSSL then Cryptopp is the crypto library you should use.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style">IV. TCP/IP<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">TCP/IP is responsible for all data transmission. Unreliable protocols are not currently supported by SSL. The system's TCP/IP is used by default and yaSSL uses it in a standard way. yaSSL does attempt to encapsulate the difference between BSD sockets and WinSock in socket_wrapper.hpp so that yaSSL does not have to concern itself with the discrepancies. <br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">Please note that the user of yaSSL is responsible for setting socket options before passing off the socket descriptor. For example, a user wishing to use a non-blocking socket must set this before handing off responsibility to yaSSL. <br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">For more information about TCP and socket options see your system documentation or a classic tome like Stevens's Unix Network Programming Volume I.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style">V. Certificates<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">TaoCrypt currently handles all x509 processing and verification. Extracting public keys, valid dates, issuer, and contact information are a few examples of certificate processing. TaoCrypt also verifies x509 validity through Certificate Authorities that the user controls. cert_wrapper.hpp declares the certificate functionality that yaSSL requires and like crypto_wrapper.hpp none of the details of TaoCrypt are used in the header so that another library can easily be substituted into cert_wrapper.cpp. yaSSL can accept certificates and keys in both PEM (Privacy Enhanced Mail) and DER (Distinguished Encoding Rules) formats.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style">VI. Input/Output Strategy<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">The yaSSL embedded SSL library uses a simulated streaming input/output system defined in buffer.hpp. The buffers behave like a smart C style array for use with overloaded &lt;&lt; and &gt;&gt; and provide a checking option, input is designed to be read from and output is for writing. std::vector is not used because of a desire to have checked []access, offset, and the ability to read/write to the buffer bulk wise while maintaining the correct size and offset. The buffers themselves use a checking policy.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">The checking policy is Check by default but may be turned off at compile time to use NoCheck. Check merely ensures that range errors are caught and is especially useful for debugging and testing, though it is a simple in-lined test, some users may prefer to avoid runtime buffer flow checks.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">One other feature worth noting about the buffers is that since they know their current offset, an index is not required for operator[]. By passing the constant AUTO, the user is freed from making silly index tracking errors, easing the burden of simple, but still error-prone, input/output programming. For example, compare the following two implementations:<br/></p>
<p class="paragraph_style_1"><br/></p>
<ol>
<li style="line-height: 17px; padding-left: 14px; text-indent: -14px; " class="full-width" value="1">
<p style="text-indent: -14px; " class="paragraph_style_2"><span style="font-size: 12px; " class="Bullet">A.</span><span style="width: 3px; " class="inline-block"></span>        // input operator for ServerHello <br/></p>
</li>
</ol>
<p class="paragraph_style_1">            input_buffer&amp; operator&gt;&gt;(input_buffer&amp; input, ServerHello&amp; hello) <br/></p>
<p class="paragraph_style_1">            { <br/></p>
<p class="paragraph_style_1">                    // Protocol <br/></p>
<p class="paragraph_style_1">                    hello.server_version_.major_ = input[AUTO]; <br/></p>
<p class="paragraph_style_1">                    hello.server_version_.minor_ = input[AUTO];<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">                    // Random <br/></p>
<p class="paragraph_style_1">                    input.read(hello.random_, RAN_LEN);<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">                    // Session <br/></p>
<p class="paragraph_style_1">                    hello.id_len_ = input[AUTO]; <br/></p>
<p class="paragraph_style_1">                    input.read(hello.session_id_, ID_LEN);<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">                    // Suites <br/></p>
<p class="paragraph_style_1">                    hello.cipher_suite_[0] = input[AUTO]; <br/></p>
<p class="paragraph_style_1">                    hello.cipher_suite_[1] = input[AUTO];<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">                    // Compression <br/></p>
<p class="paragraph_style_1">                    hello.compression_method_ = CompressionMethod(input[AUTO]);<br/></p>
<p class="paragraph_style_1">                    return input; <br/></p>
<p class="paragraph_style_1">            }<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1"><br/></p>
<ol>
<li style="line-height: 17px; padding-left: 15px; text-indent: -15px; " class="full-width" value="2">
<p style="text-indent: -15px; " class="paragraph_style_3"><span style="font-size: 12px; " class="Bullet">B.</span><span style="width: 3px; " class="inline-block"></span>        // input operator for ServerHello <br/></p>
</li>
</ol>
<p class="paragraph_style_4">            input_buffer&amp; operator&gt;&gt;(input_buffer&amp; input, ServerHello&amp; hello) <br/></p>
<p class="paragraph_style_4">            { <br/></p>
<p class="paragraph_style_4">                    size_t i = input.get_current();<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">                    // Protocol <br/></p>
<p class="paragraph_style_1">                    hello.server_version_.major_ = input[i++]; <br/></p>
<p class="paragraph_style_1">                    hello.server_version_.minor_ = input[i++];<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">                    // Random <br/></p>
<p class="paragraph_style_1">                    input.read(hello.random_, RAN_LEN); <br/></p>
<p class="paragraph_style_1">                    i += RAN_LEN;<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">                    // Session <br/></p>
<p class="paragraph_style_1">                    hello.id_len_ = input[i++]; <br/></p>
<p class="paragraph_style_1">                    input.read(hello.session_id_, ID_LEN); <br/></p>
<p class="paragraph_style_1">                    i += ID_LEN;<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">                    // Suites <br/></p>
<p class="paragraph_style_1">                    hello.cipher_suite_[0] = input[i++]; <br/></p>
<p class="paragraph_style_1">                    hello.cipher_suite_[1] = input[i++];<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">                    // Compression <br/></p>
<p class="paragraph_style_1">                    hello.compression_method_ = <br/></p>
<p class="paragraph_style_1">                    CompressionMethod(input[i++]);<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">                    input.set_current(i);<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">                    return input; <br/></p>
<p class="paragraph_style_1">            }<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">While B is not much more difficult to implement, the chances for simple errors to occur are increased. Not to mention having to remember to get/set the current offset before passing the buffer to handlers and in the event of exceptions, there is no guarantee that the index is correctly positioned, making recovery nearly impossible.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style">VII. Factory Usage<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">Factories are used in several areas by yaSSL. Many of the structures defined in the SSL standard obey the Liskov Substitution Principle (Functions that use pointers/references to base classes must be able to use objects of derived classes transparently). That is, a ServerHello message IS A handshake message and a Finished message IS also A handshake message. Moreover, objects of the derived classes need to be created at runtime based on the negotiated parameters of the connection and message types. For example, when a message header is read, a type field identifies the message that follows. Instead of using a switch statement that becomes increasingly harder to maintain, yaSSL uses a message factory to create the desired object.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">            Message* msg = MessageFactory.CreateObject(hdr.type_);<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">factory.hpp defines the generic implementation like this:<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">            template <br/></p>
<p class="paragraph_style_1">            &lt; <br/></p>
<p class="paragraph_style_1">                    class AbstractProduct, <br/></p>
<p class="paragraph_style_1">                    typename IdentifierType = int, <br/></p>
<p class="paragraph_style_1">                    typename ProductCreator = AbstractProduct* (*)() <br/></p>
<p class="paragraph_style_1">            &gt; <br/></p>
<p class="paragraph_style_1">            class Factory { <br/></p>
<p class="paragraph_style_1">                    typedef std::map CallBackMap; <br/></p>
<p class="paragraph_style_1">                    CallBackMap callbacks_; <br/></p>
<p class="paragraph_style_1">            ...}<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">The Message Factory instance is created like this:<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">            typedef Factory MessageFactory;<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">For more information on factories please see the design pattern discussion in (GoF) and Alexandrescu's chapter in Modern C++ Design.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style">VIII. Cryptographic Policies<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">Cryptographic Policies are employed to simplify yaSSL's use of digests, ciphers, and signature systems. Each is briefly described and defined in crypto_wrapper.hpp.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">Digests, or MACs (Message Authentication Codes) use a basic policy that hides the underlying implementation:<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">            struct MAC { <br/></p>
<p class="paragraph_style_1">                    virtual void get_digest(byte*) = 0; <br/></p>
<p class="paragraph_style_1">                    virtual void get_digest(byte*, const byte*, unsigned int) = 0; <br/></p>
<p class="paragraph_style_1">                    virtual void update(const byte*, unsigned int) = 0; <br/></p>
<p class="paragraph_style_1">            ...}<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">Really only the first get_digest() and update() are needed but the extended version of get_digest() allows a user to both update and retrieve the digest in the same call, simplifying some operations. MD5 and SHA use the policy in their definitions, here is SHA as an example:<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">            class SHA : public MAC {<br/></p>
<p class="paragraph_style_1">            public: <br/></p>
<p class="paragraph_style_1">                    void get_digest(byte*); <br/></p>
<p class="paragraph_style_1">                    void get_digest(byte*, const byte*, unsigned int); <br/></p>
<p class="paragraph_style_1">                    void update(const byte*, unsigned int); <br/></p>
<p class="paragraph_style_1">            ...}<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">So when yaSSL has a MAC pointer, it uses it without knowledge of the derived object actually being used, conforming to the Liskov Substitution Principle.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">Ciphers also employ a basic policy:<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">            struct BulkCipher { <br/></p>
<p class="paragraph_style_1">                    virtual void encrypt(byte*, const byte*, unsigned int) = 0; <br/></p>
<p class="paragraph_style_1">                    virtual void decrypt(byte*, const byte*, unsigned int) = 0; <br/></p>
<p class="paragraph_style_1">                    virtual void set_encryptKey(const byte*, const byte* = 0) = 0; <br/></p>
<p class="paragraph_style_1">                    virtual void set_decryptKey(const byte*, const byte* = 0) = 0; <br/></p>
<p class="paragraph_style_1">            ...}<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">These functions are all necessary and yaSSL uses BulkCipher pointers transparently and without knowledge of whether the actual object is DES, 3DES, or RC4.  Authentication policies define the signature verification interface used by yaSSL.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">            struct Auth { <br/></p>
<p class="paragraph_style_1">                    virtual void sign(byte*, const byte*, unsigned int, const RandomPool&amp;) =0; <br/></p>
<p class="paragraph_style_1">                    virtual bool verify(const byte*, unsigned int, const byte*, unsigned int) = 0; <br/></p>
<p class="paragraph_style_1">            ...}<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">The authentication policy is straight forward and support for DSS and RSA is built into yaSSL.<br/></p>
<p class="paragraph_style_1"><br/></p>
<ol>
<li style="line-height: 22px; padding-left: 24px; text-indent: -24px; " class="full-width" value="9">
<p style="text-indent: -24px; " class="paragraph_style_5"><span style="font-size: 16px; position: relative; top: 0px; " class="Bullet">IX.</span><span style="width: 4px; " class="inline-block"></span>Thread Safe<br/></p>
</li>
</ol>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">yaSSL is thread safe by design. Multiple threads can enter the library simultaneously without creating conflicts because yaSSL avoids global data, static data, and the sharing of objects. The user must still take care to avoid potential problems in two areas.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">A client may share an SSL object across multiple threads but access must be synchronized, i.e., trying to read/write at the same time from two different threads with the same SSL pointer is not supported.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">yaSSL could take a more aggressive (constrictive) stance and lock out other users when a function is entered that cannot be shared but this level of granularity seems counter-intuitive.  All users (even single threaded ones) will pay for the locking and multi-thread ones won't be able to re-enter the library even if they aren't sharing objects across threads. This penalty seems much too high and yaSSL leaves the responsibility of synchronizing shared objects in the hands of the user.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">Besides sharing SSL pointers, users must also take care to completely initialize an SSL_CTX before passing the structure to SSL_new(). The same SSL_CTX can create multiple SSLs but the SSL_CTX is only read during SSL_new() creation and any future (or simultaneous changes) to the SSL_CTX will not be reflected once the SSL object is created.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">Again, multiple threads should synchronize writing access to a SSL_CTX and it is advised that a single thread initialize the SSL_CTX to avoid the synchronization and update problem described above.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_6">X. Thread Caching<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">yaSSL supports session caching, which can greatly decrease the connection processing time when clients re-issue connects within a relatively short time (the default is to cache for 500 seconds). Access to the cache is internally stored in yaSSL with a Singleton and is the only part of the library which isn't thread safe. For users that aren't multi-threaded or don't plan on using session caching and don't want to pay for the locking of this cache, please define SINGLE_THREADED when compiling yaSSL.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_6">XI. Memory Usage<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">yaSSL doesn't pre-allocate any memory up front for a connection. This allows users to create a large pool of connection objects without paying for a large memory hit. yaSSL only requests memory when it needs it, and returns it to the system when it no longer needs it. yaSSL requires about 32K of memory for a connection (this includes 6K for 3 certificates, and the total will vary depending on certificate size and number as well as the type of connection). After that, yaSSL only requires about 500 bytes of memory to send or receive an SSL message. Users wishing to pre-allocate memory, or take over the memory handling in any way, can implement their own ::operator new and delete.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_6">XII. Supported Cipher Suites<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">The following Cipher Suites are supported by yaSSL:<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">SSL_RSA_WITH_RC4_128_MD5 <br/></p>
<p class="paragraph_style_1">SSL_RSA_WITH_RC4_128_SHA <br/></p>
<p class="paragraph_style_1">SSL_RSA_WITH_DES_CBC_SHA <br/></p>
<p class="paragraph_style_1">SSL_RSA_WITH_3DES_EDE_CBC_SHA <br/></p>
<p class="paragraph_style_1">SSL_DHE_DSS_WITH_DES_CBC_SHA <br/></p>
<p class="paragraph_style_1">SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA <br/></p>
<p class="paragraph_style_1">SSL_DHE_RSA_WITH_DES_CBC_SHA <br/></p>
<p class="paragraph_style_1">SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA <br/></p>
<p class="paragraph_style_1">TLS_RSA_WITH_AES_128_CBC_SHA <br/></p>
<p class="paragraph_style_1">TLS_DHE_DSS_WITH_AES_128_CBC_SHA <br/></p>
<p class="paragraph_style_1">TLS_DHE_RSA_WITH_AES_128_CBC_SHA <br/></p>
<p class="paragraph_style_1">TLS_RSA_WITH_AES_256_CBC_SHA <br/></p>
<p class="paragraph_style_1">TLS_DHE_DSS_WITH_AES_256_CBC_SHA <br/></p>
<p class="paragraph_style_1">TLS_DHE_RSA_WITH_AES_256_CBC_SHA <br/></p>
<p class="paragraph_style_1">TLS_DHE_DSS_WITH_3DES_EDE_CBC_RMD160 <br/></p>
<p class="paragraph_style_1">TLS_DHE_DSS_WITH_AES_128_CBC_RMD160 <br/></p>
<p class="paragraph_style_1">TLS_DHE_DSS_WITH_AES_256_CBC_RMD160 <br/></p>
<p class="paragraph_style_1">TLS_DHE_RSA_WITH_3DES_EDE_CBC_RMD160 <br/></p>
<p class="paragraph_style_1">TLS_DHE_RSA_WITH_AES_128_CBC_RMD160 <br/></p>
<p class="paragraph_style_1">TLS_DHE_RSA_WITH_AES_256_CBC_RMD160 <br/></p>
<p class="paragraph_style_1">TLS_RSA_WITH_3DES_EDE_CBC_RMD160 <br/></p>
<p class="paragraph_style_1">TLS_RSA_WITH_AES_128_CBC_RMD160 <br/></p>
<p class="paragraph_style_1">TLS_RSA_WITH_AES_256_CBC_RMD160<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_6">XIII. Removing C++ Symbols<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">yaSSL is implemented in C++. For those users wishing to use a version of yaSSL without any global C++ symbols, there is a way to achieve this using GCC. Just define YASSL_PURE_C when building yaSSL. No exceptions, RTTI, std library, or global allocators will be defined.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_6">XIV. Conclusion<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">The combination of yaSSL's buffer strategy and factory use provides a simple paradigm used throughout the handshake and message layer implementations. Reading and processing an input message could not be simpler:<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">            while(!buffer.eof()) { <br/></p>
<p class="paragraph_style_1">                    // each record <br/></p>
<p class="paragraph_style_1">                    RecordLayerHeader hdr; <br/></p>
<p class="paragraph_style_1">                    buffer &gt;&gt; hdr;<br/></p>
<p class="paragraph_style_1">                    while (buffer.get_current() &lt; hdr.length_ + offset) { <br/></p>
<p class="paragraph_style_1">                                // each message in record <br/></p>
<p class="paragraph_style_1">                                std::auto_ptr msg(mf.CreateObject(hdr.type_)); <br/></p>
<p class="paragraph_style_1">                                buffer &gt;&gt; *msg; <br/></p>
<p class="paragraph_style_1">                                msg-&gt;Process(buffer, ssl); <br/></p>
<p class="paragraph_style_1">                    } <br/></p>
<p class="paragraph_style_1">                    offset += hdr.length_ <br/></p>
<p class="paragraph_style_1">            }<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">This same loop is used by both clients and servers and efficiently handles all message types. Handshake processing uses the exact same paradigm. Sending an SSL output messages in yaSSL is primarily the responsibilityof the output buffer and some simple helper functions like buildHeader() and buildOutput(). Their implementations are also simple.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">            void buildHeader(SSL&amp; ssl, RecordLayerHeader&amp; rlHeader, const Message&amp; msg) <br/></p>
<p class="paragraph_style_1">            { <br/></p>
<p class="paragraph_style_1">                    ProtocolVersion pv = ssl.get_connection().version_; <br/></p>
<p class="paragraph_style_1">                    rlHeader.type_ = msg.get_type(); <br/></p>
<p class="paragraph_style_1">                    rlHeader.version_.major_ = pv.major_; <br/></p>
<p class="paragraph_style_1">                    rlHeader.version_.minor_ = pv.minor_;<br/></p>
<p class="paragraph_style_1">                    rlHeader.length_ = msg.get_length(); <br/></p>
<p class="paragraph_style_1">            }<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">            void buildOutput(output_buffer&amp; buffer, const RecordLayerHeader&amp; rlHdr, <br/></p>
<p class="paragraph_style_1">                                       const HandShakeHeader&amp; hsHdr, const HandShakeBase&amp; shake) <br/></p>
<p class="paragraph_style_1">            { <br/></p>
<p class="paragraph_style_1">                    buffer.allocate(RECORD_HEADER + rlHdr.length_); <br/></p>
<p class="paragraph_style_1">                    buffer &lt;&lt; rlHdr &lt;&lt; hsHdr &lt;&lt; shake; <br/></p>
<p class="paragraph_style_1">            }<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">In fact, using the above functions and a couple of other helpers reveal the ease with which yaSSL sends a client hello message:<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">            void sendClientHello(SSL&amp; ssl)<br/></p>
<p class="paragraph_style_1">            { <br/></p>
<p class="paragraph_style_1">                    ClientHello ch; <br/></p>
<p class="paragraph_style_1">                    RecordLayerHeader rlHeader; <br/></p>
<p class="paragraph_style_1">                    HandShakeHeader hsHeader; <br/></p>
<p class="paragraph_style_1">                    output_buffer out;<br/></p>
<p class="paragraph_style_1">                    buildClientHello(ssl, ch); <br/></p>
<p class="paragraph_style_1">                    ssl.set_random(ch.get_random(), client_end); <br/></p>
<p class="paragraph_style_1">                    buildHeaders(ssl, hsHeader, rlHeader, ch); <br/></p>
<p class="paragraph_style_1">                    buildOutput(out, rlHeader, hsHeader, ch); <br/></p>
<p class="paragraph_style_1">                    hashHandShake(ssl, out);<br/></p>
<p class="paragraph_style_1">                    ssl.get_socket().send(out.get_buffer(), out.get_size()); <br/></p>
<p class="paragraph_style_1">            }<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1">Please see handshake.cpp and yassl_imp.cpp for a better understanding of how yaSSL sends and retrieves the other messages and handshake types.<br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1"><br/></p>
<p class="paragraph_style_1"><br/></p>
<p style="padding-bottom: 0pt; " class="paragraph_style_7">Copyright 2017 wolfSSL Inc.  All rights reserved.</p>
</div>
</div>
</div>
<div id="id2" style="height: 37px; left: 414px; position: absolute; top: 157px; width: 322px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_322_37" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_8">yaSSL Architecture and Design</p>
</div>
</div>
</div>
<div id="id3" style="height: 23px; left: 193px; position: absolute; top: 122px; width: 222px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_222_23" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_9"><a class="class2" title="Docs.html" href="Docs.html">Docs</a> <span class="style">-&gt;</span> <span class="style_1">yaSSL Architecture and Design</span></p>
</div>
</div>
</div>
<div style="height: 1px; width: 681px;  height: 1px; left: 52px; position: absolute; top: 220px; width: 681px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 681px; ">
<img src="Docs_yaSSL_Architecture_and_Design_files/shapeimage_1.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 681px; "/>
</div>
</div>
<div style="height: 37px; width: 545px;  height: 37px; left: 191px; position: absolute; top: 80px; width: 545px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 545px; ">
<img src="Docs_yaSSL_Architecture_and_Design_files/shapeimage_2.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 545px; "/>
</div>
</div>
<div id="id4" style="height: 25px; left: 200px; position: absolute; top: 84px; width: 43px; z-index: 1; " class="style_SkipStroke_1 shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_43_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_10"><a class="class3" title="Home.html" href="Home.html">Home</a></p>
</div>
</div>
</div>
<div id="id5" style="height: 25px; left: 365px; position: absolute; top: 84px; width: 72px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_72_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_11"><a class="class4" title="https://wolfssl.com/wolfSSL/download/downloadForm.php" href="https://wolfssl.com/wolfSSL/download/downloadForm.php">Download</a></p>
</div>
</div>
</div>
<div id="id6" style="height: 25px; left: 439px; position: absolute; top: 84px; width: 59px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_59_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_11"><a class="class5" title="License.html" href="License.html">License</a></p>
</div>
</div>
</div>
<div id="id7" style="height: 25px; left: 499px; position: absolute; top: 84px; width: 44px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_44_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_11"><a class="class6" title="Blog/Blog.html" href="Blog/Blog.html">Blog</a></p>
</div>
</div>
</div>
<div id="id8" style="height: 25px; left: 589px; position: absolute; top: 84px; width: 80px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_80_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_11"><a class="class7" title="Community.html" href="Community.html">Community</a></p>
</div>
</div>
</div>
<div style="height: 36px; width: 1px;  height: 36px; left: 245px; position: absolute; top: 81px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs_yaSSL_Architecture_and_Design_files/shapeimage_3.png" alt="" style="height: 36px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 37px; width: 1px;  height: 37px; left: 296px; position: absolute; top: 80px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs_yaSSL_Architecture_and_Design_files/shapeimage_4.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 36px; width: 1px;  height: 36px; left: 363px; position: absolute; top: 81px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs_yaSSL_Architecture_and_Design_files/shapeimage_5.png" alt="" style="height: 36px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 36px; width: 1px;  height: 36px; left: 438px; position: absolute; top: 81px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs_yaSSL_Architecture_and_Design_files/shapeimage_6.png" alt="" style="height: 36px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 37px; width: 1px;  height: 37px; left: 498px; position: absolute; top: 80px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs_yaSSL_Architecture_and_Design_files/shapeimage_7.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 37px; width: 1px;  height: 37px; left: 589px; position: absolute; top: 80px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs_yaSSL_Architecture_and_Design_files/shapeimage_8.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div id="id9" style="height: 25px; left: 671px; position: absolute; top: 84px; width: 61px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_61_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_11"><a class="class8" title="Contact.html" href="Contact.html">Contact</a></p>
</div>
</div>
</div>
<div id="id10" style="height: 25px; left: 249px; position: absolute; top: 84px; width: 44px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_44_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_10"><a class="class9" title="About.html" href="About.html">About</a></p>
</div>
</div>
</div>
<div style="height: 36px; width: 1px;  height: 36px; left: 670px; position: absolute; top: 81px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs_yaSSL_Architecture_and_Design_files/shapeimage_9.png" alt="" style="height: 36px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div id="id11" style="height: 25px; left: 298px; position: absolute; top: 84px; width: 63px; z-index: 1; " class="style_SkipStroke_1 shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_63_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_11"><a class="class10" title="Products.html" href="Products.html">Products</a></p>
</div>
</div>
</div>
<div id="id12" style="height: 25px; left: 549px; position: absolute; top: 84px; width: 41px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_41_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_10"><a class="class11" title="Docs.html" href="Docs.html">Docs</a></p>
</div>
</div>
</div>
<div style="height: 37px; width: 1px;  height: 37px; left: 545px; position: absolute; top: 80px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs_yaSSL_Architecture_and_Design_files/shapeimage_10.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div id="id13" style="height: 27px; left: 75px; position: absolute; top: 190px; width: 97px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_97_27" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_12"><a class="class12" title="http://www.yassl.com/documentation/yaSSL_Architecture_and_Design.pdf" href="http://www.yassl.com/documentation/yaSSL_Architecture_and_Design.pdf">Download PDF</a></p>
</div>
</div>
</div>
<div style="height: 22px; width: 22px;  height: 22px; left: 49px; position: absolute; top: 191px; width: 22px; z-index: 1; " class="tinyText style_SkipStroke_2">
<img src="Docs_yaSSL_Architecture_and_Design_files/PDF.png" alt="" style="border: none; height: 22px; width: 22px; "/>
</div>
<div style="height: 16px; width: 20px;  height: 16px; left: 706px; position: absolute; top: 51px; width: 20px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 20px; ">
<img src="Docs_yaSSL_Architecture_and_Design_files/shapeimage_11.png" alt="" style="height: 16px; left: 0px; position: absolute; top: 0px; width: 20px; "/>
</div>
</div>
<div style="height: 19px; width: 19px;  height: 19px; left: 707px; position: absolute; top: 25px; width: 19px; z-index: 1; " class="tinyText style_SkipStroke_2">
<img src="Docs_yaSSL_Architecture_and_Design_files/United%20Kingdom(Great%20Britain).png" alt="" style="border: none; height: 19px; width: 19px; "/>
</div>
<div id="id14" style="height: 23px; left: 328px; position: absolute; top: 48px; width: 258px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_258_23" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_13">Questions? +1 (425) 245-8247</p>
</div>
</div>
</div>
<div style="height: 19px; width: 19px;  height: 19px; left: 685px; position: absolute; top: 25px; width: 19px; z-index: 1; " class="tinyText style_SkipStroke_2">
<a href="http://www.wolfssl.jp/" title="http://www.wolfssl.jp"><img src="Docs_yaSSL_Architecture_and_Design_files/japan.png" alt="" style="border: none; height: 19px; width: 19px; "/></a>
</div>
<div id="id15" style="height: 28px; left: 593px; position: absolute; top: 44px; width: 119px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_119_28" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_14"><a class="class13" title="https://www.wolfssl.com/forums" href="https://www.wolfssl.com/forums">Support <span class="style_2">Forums</span></a></p>
</div>
</div>
</div>
<div style="height: 121px; width: 155px;  height: 121px; left: 32px; position: absolute; top: 5px; width: 155px; z-index: 1; " class="tinyText style_SkipStroke_2">
<a href="Home.html" title="Home.html"><img src="Docs_yaSSL_Architecture_and_Design_files/wolfssl_logo.png" alt="" style="border: none; height: 121px; width: 156px; "/></a>
</div>
<div style="height: 5998px; line-height: 5998px; " class="spacer"> </div>
</div>
<div style="height: 100px; margin-left: 0px; position: relative; width: 770px; z-index: 15; " id="footer_layer">
<div style="height: 0px; line-height: 0px; " class="bumper"> </div>
</div>
</div>
</div>
 </body>

<!-- Mirrored from www.wolfssl.com/wolfSSL/Docs_yaSSL_Architecture_and_Design.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Jan 2017 13:24:21 GMT -->
</html>
